package com.behome.netty.netty_D.bean;

import com.behome.netty.common.ByteConventerKit;
import com.behome.netty.netty_D.enums.TerminalDAnnotation;
import com.behome.netty.netty_D.enums.TerminalDType;
import io.netty.util.internal.StringUtil;

/** 
 * @description: 终端D停止广播
 * @author bh_ljy
 * @date: 2024/5/27 15:15
 */ 
@TerminalDAnnotation(
        type = TerminalDType.STOP_BROADCAST
)
public class TerminalDStopBroadcast extends BusinessCmdBase {
    private String ebmid;

    public TerminalDStopBroadcast() {
    }

    public String getEbmid() {
        return this.ebmid;
    }

    public void setEbmid(String ebmid) {
        this.ebmid = ebmid;
    }

    public byte[] serialize() {
        return !this.validateBeforeSerialize() ? null : ByteConventerKit.serializeEbmId(this.ebmid);
    }

    public boolean validateBeforeSerialize() {
        if (StringUtil.isNullOrEmpty(this.ebmid)) {
            throw new IllegalArgumentException("ebmid为空,不能序列化.");
        } else {
            return true;
        }
    }

    public BusinessCmdBase deserialize(byte[] businessData) {
        TerminalDStopBroadcast ret = new TerminalDStopBroadcast();
        ret.ebmid = ByteConventerKit.deserializeEbmId(businessData);
        return ret;
    }
}
